#pragma once
#include "protocolBase.h"


#pragma pack(push, 1)
struct DataFrameHeader
{
	uint8_t header0;   //0xA5
	uint8_t header1;   //0x5A
	// uint8_t id;        //src
	// uint8_t dst;
	uint8_t cmd;
};
struct DataFrame
{
	DataFrameHeader header;
	uint8_t len;
	uint8_t* data;
	uint16_t check_sum;
	uint8_t tail;   //0xFE
};
#pragma pack(pop)  

class SerialProrocol:public ProrocolBase
{

public:
    SerialProrocol(uint32_t bufSize);
    virtual ~SerialProrocol();

    virtual const uint8_t* packageBuffer(const uint8_t* buf, uint32_t inlen, int32_t& outlen) override;

private:
    uint16_t CRC16_Check(const uint8_t *data,uint8_t len);

    virtual int pushByte(uint8_t point) override;

    uint8_t header0;
    uint8_t header0;

};
